package com.sinosoft.cnmuseum.servlets;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sinosoft.cnmuseum.dao.MbManageAudiofrequencyDao;
import com.sinosoft.cnmuseum.dao.MbManageImageDao;
import com.sinosoft.cnmuseum.dao.MbManageLiteratureDao;
import com.sinosoft.cnmuseum.dao.MbManageThreedimensionalmodelDao;
import com.sinosoft.cnmuseum.dao.MbManageVideoDao;
import com.sinosoft.cnmuseum.dao.MbMusicGcxxDao;
import com.sinosoft.cnmuseum.dao.MbXtglJsglDao;
import com.sinosoft.cnmuseum.dao.MbXtglRyjsfpDao;
import com.sinosoft.cnmuseum.dao.flownumDao;
import com.sinosoft.cnmuseum.entity.MbGyHsfl;
import com.sinosoft.cnmuseum.entity.MbGyMjfl;
import com.sinosoft.cnmuseum.entity.MbManageAudiofrequency;
import com.sinosoft.cnmuseum.entity.MbManageImage;
import com.sinosoft.cnmuseum.entity.MbManageLiterature;
import com.sinosoft.cnmuseum.entity.MbManageThreedimensionalmodel;
import com.sinosoft.cnmuseum.entity.MbManageVideo;
import com.sinosoft.cnmuseum.entity.MbMusicDbrw;
import com.sinosoft.cnmuseum.entity.MbMusicGcxx;
import com.sinosoft.cnmuseum.entity.MbMusicWhrlxxx;
import com.sinosoft.cnmuseum.entity.MbMusicWhsx;
import com.sinosoft.cnmuseum.entity.MbMusicXzxx;
import com.sinosoft.cnmuseum.entity.MbMusicYxxx;
import com.sinosoft.cnmuseum.entity.MbXtglRyjsfp;
import com.sinosoft.cnmuseum.utils.AcquisitionUtils;
import com.sinosoft.cnmuseum.utils.MusicSaveOrUpdateUtil;
import com.sinosoft.cnmuseum.utils.PageUtil;
import com.sinosoft.cnmuseum.utils.Status;
import com.sinosoft.cnmuseum.utils.StringUtils;
import com.sinosoft.commontools.annotated.TransAnnotation;
import com.sinosoft.commontools.annotated.rquestMethod;
import com.sinosoft.commontools.annotated.rquestMethod.ReqMode;
import com.sinosoft.commontools.record.Record;

public class BjFlowServlet {
	
	
	/**      
	 * getBjData 编辑流程-编辑步骤-编辑人，查询待办
	 * @author wangli
	 * @param request
	 * @param response
	 * @param data
	 * @return          
	*/
	@rquestMethod(MethodNote = ReqMode.All)
	public Record getBjData(HttpServletRequest request, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			int pagenumber = data.getIntValue(Status.PAGENUMBER);// 获取当前页
			int pagesize = data.getIntValue(Status.PAGESIZE);// 获取每页多少条数据
			HttpSession session = request.getSession(false);
			String userid = (String) session.getAttribute(Status.SESSION_USERID);
			// 编辑流程数据   不是最新数据，流程有效
			String countsql = "select count(*) as count from mb_music_gcxx where isnew=0 and isrunning=1 ";
			String sql = "select * from mb_music_gcxx where isnew=0 and isrunning=1 ";
			String ordersql = " order by id desc ";
			String limitsql = " limit ";
			// 编辑人查询的流程步骤为编辑步骤 bj
			countsql += " and flowid like '%bj' ";
			sql      += " and flowid like '%bj' ";
			// 多选分配人 字段包含当前人ID
//			countsql += " and assigneeusers like '%,"+userid+",%' ";
//			sql      += " and assigneeusers like '%,"+userid+",%' ";
			// 分配人为当前人 或者 分配人为空
			countsql += " and (assigneeuser = '"+userid+"' or assigneeuser ='') ";
			sql      += " and (assigneeuser = '"+userid+"' or assigneeuser ='') ";
			
			// 查询条件,藏品号
			String collection_code = data.getStrValue("collection_code");
			if(StringUtils.isNoEmpty(collection_code)){
				countsql += " and collection_code like '%"+collection_code+"%%' ";
				sql      += " and collection_code like '%"+collection_code+"%%' ";
			}
			
			// 查询条件,根据名称模糊查询
			String title = data.getStrValue("yqmc");
			if(StringUtils.isNoEmpty(title)){
				countsql += " and title like '%"+title+"%' ";
				sql      += " and title like '%"+title+"%' ";
			}
			
			// 查询条件,根据八音分类查询
			String class_bayin1 = data.getStrValue("class_bayin");
			if(StringUtils.isNoEmpty(class_bayin1)){
				countsql += " and class_bayin ="+class_bayin1;
				sql      += " and class_bayin ="+class_bayin1;;
			}
			
			// 查询条件,根据民间分类查询
			String class_minjian1 = data.getStrValue("class_minjian");
			if(StringUtils.isNoEmpty(class_minjian1)){
				countsql += " and class_minjian ="+class_minjian1;
				sql      += " and class_minjian ="+class_minjian1;;
			}
			
			// 查询条件,根据霍萨分类查询
			String class_huosa1 = data.getStrValue("class_huosa");
			if(StringUtils.isNoEmpty(class_huosa1)){
				countsql += " and class_huosa ="+class_huosa1;
				sql      += " and class_huosa ="+class_huosa1;;
			}
			
			// 查询条件,根据年代查询
			String year1 = data.getStrValue("year");
			if(StringUtils.isNoEmpty(year1)){
				countsql += " and year like '%"+year1+"%' ";
				sql      += " and year like '%"+year1+"%' ";
			}
			
			// 查询条件,根据出土地点查询
			String unearthedplace = data.getStrValue("unearthedplace");
			if(StringUtils.isNoEmpty(unearthedplace)){
				countsql += " and unearthedplace like '%"+unearthedplace+"%' ";
				sql      += " and unearthedplace like '%"+unearthedplace+"%' ";
			}
			
			// 查询条件,根据采集地点查询
			String collectionPlace = data.getStrValue("collectionPlace");
			if(StringUtils.isNoEmpty(collectionPlace)){
				countsql += " and collectionPlace like '%"+collectionPlace+"%' ";
				sql      += " and collectionPlace like '%"+collectionPlace+"%' ";
			}
			
			MbMusicGcxxDao gcxxdao = new MbMusicGcxxDao();
			List<Record> countlist = gcxxdao.getBySql(countsql);
			int total = countlist.get(0).getIntValue("count");//获得总记录数
			PageUtil page = new PageUtil(pagenumber, pagesize, total);
			limitsql += page.getStart()+","+pagesize;
			List<Record> list = gcxxdao.getBySql(sql+ordersql+limitsql);
			// 组装数据
			// 获取上一步骤 preflowstep
			if(list!=null&&list.size()>0){
				for(Record r:list){
					String nowflowid = r.getStrValue(MbMusicGcxx.FLOWID);
					String flowss[] = nowflowid.split("_");
					String flowmainid = flowss[1];
					String laststep = gcxxdao.getLastFlowstep(flowmainid);
					r.add("preflowstep", laststep);
				}
			}
			record.add(Status.ROWS, list);
			record.add(Status.TOTAL, total);
			record.add(Status.PAGENUMBER, pagenumber);
			record.add(Status.PAGESIZE, pagesize);
			record.add(Status.PAGETOTAL, page.getPagetotal());
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}
	
	
	/**      
	 * getBjLrData  编辑流程-专家辅助录入步骤-专家，查询待办
	 * @author wangli
	 * @param request
	 * @param response
	 * @param data
	 * @return          
	*/
	@rquestMethod(MethodNote = ReqMode.All)
	public Record getBjLrData(HttpServletRequest request, HttpServletResponse response, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			int pagenumber = data.getIntValue(Status.PAGENUMBER);// 获取当前页
			int pagesize = data.getIntValue(Status.PAGESIZE);// 获取每页多少条数据
			HttpSession session = request.getSession(false);
			String userid = (String) session.getAttribute(Status.SESSION_USERID);
			// 编辑流程数据   不是最新数据，流程有效
			String countsql = "select count(*) as count from mb_music_sjjs_lc where 1=1 ";
			String sql      = "select * from mb_music_sjjs_lc where 1=1 ";
			String ordersql = " order by id desc ";
			String limitsql = " limit ";
			// 专家查询的流程步骤为辅助录入步骤 bj_lr
			countsql += " and flowid like '%bjlr' ";
			sql      += " and flowid like '%bjlr' ";
//			MbXtglRyjsfpDao ryjsfpdao = new MbXtglRyjsfpDao();
//			MbXtglJsglDao jsgldao = new MbXtglJsglDao();
//			int id = Integer.parseInt(userid);
//			List<Record> jslist = ryjsfpdao.getByRybm(id);
//			String rolesstr = " and ( ";
//			if(jslist!=null){
//				for(int i=0;i<jslist.size();i++){
//					Record jsobj = jslist.get(i);
//					String jsbm = jsobj.getStrValue(MbXtglRyjsfp.JSBM);
//					if(i>0){
//						rolesstr += " or ";
//					}
//					String jszdbh = jsgldao.getJsZdbh(jsbm);
//					if(StringUtils.isNoEmpty(jsbm)){
//						rolesstr += " assigneeroles like '%,"+jszdbh+",%' ";
//					}
//				}
//			}else{
//				
//			}
//			rolesstr += " ) ";
			// 多选分配角色 字段包含当前人角色
//			countsql += rolesstr;
//			sql += rolesstr;
			// 分配人为当前人 或者 分配人为空
//			countsql += " and (assigneeuser = '"+userid+"' or assigneeuser ='') ";
//			sql      += " and (assigneeuser = '"+userid+"' or assigneeuser ='') ";
            countsql += " and (assigneeusers like '%,"+userid+",%') ";
            sql      += " and (assigneeusers like '%,"+userid+",%') ";
			// 查询条件,藏品号
			String collection_code = data.getStrValue("collection_code");
			if(StringUtils.isNoEmpty(collection_code)){
				countsql += " and collection_code like '%"+collection_code+"%' ";
				sql      += " and collection_code like '%"+collection_code+"%' ";
			}
			
			// 查询条件,根据名称模糊查询
			String title = data.getStrValue("yqmc");
			if(StringUtils.isNoEmpty(title)){
				countsql += " and title like '%"+title+"%' ";
				sql      += " and title like '%"+title+"%' ";
			}
			
			// 查询条件,根据八音分类查询
			String class_bayin1 = data.getStrValue("class_bayin");
			if(StringUtils.isNoEmpty(class_bayin1)){
				countsql += " and class_bayin ="+class_bayin1;
				sql      += " and class_bayin ="+class_bayin1;;
			}
			
			// 查询条件,根据民间分类查询
//			String class_minjian1 = data.getStrValue("class_minjian");
//			if(StringUtils.isNoEmpty(class_minjian1)){
//				countsql += " and class_minjian ="+class_minjian1;
//				sql      += " and class_minjian ="+class_minjian1;;
//			}
//			
//			// 查询条件,根据霍萨分类查询
//			String class_huosa1 = data.getStrValue("class_huosa");
//			if(StringUtils.isNoEmpty(class_huosa1)){
//				countsql += " and class_huosa ="+class_huosa1;
//				sql      += " and class_huosa ="+class_huosa1;;
//			}
			
			// 查询条件,根据民间分类
            String class_minjian = data.getStrValue("class_minjian");
            String class_minjian_showchild = data.getStrValue("class_minjian_showchild");
            if(StringUtils.isNoEmpty(class_minjian_showchild)){
              MbXtglBaseTableServlet servlet = new MbXtglBaseTableServlet();
              if(StringUtils.isNoEmpty(class_minjian)){
                class_minjian = servlet.getAllChildrenId4Select(Integer.valueOf(class_minjian), "mb_gy_mjfl");
                countsql += " and class_minjian in ("+class_minjian+")";
                sql      += " and class_minjian in ("+class_minjian+")";
              }
            }else{
              if(StringUtils.isNoEmpty(class_minjian)){
                countsql += " and class_minjian ="+class_minjian;
                sql      += " and class_minjian ="+class_minjian;;
              }
            }
            
            // 查询条件,根据霍萨分类
//          String class_huosa = data.getStrValue("class_huosa");
//          if(StringUtils.isNoEmpty(class_huosa)){
//              countsql += " and class_huosa ="+class_huosa;
//              sql      += " and class_huosa ="+class_huosa;;
//          }
            

            String class_huosa = data.getStrValue("class_huosa");
            String class_huosa_showchild = data.getStrValue("class_huosa_showchild");
            if(StringUtils.isNoEmpty(class_huosa_showchild)){
              MbXtglBaseTableServlet servlet = new MbXtglBaseTableServlet();
              if(StringUtils.isNoEmpty(class_huosa)){
                class_huosa = servlet.getAllChildrenId4Select(Integer.valueOf(class_huosa), "mb_gy_hsfl");
                countsql += " and class_huosa in ("+class_huosa+")";
                sql      += " and class_huosa in ("+class_huosa+")";
              }
            }else{
              if(StringUtils.isNoEmpty(class_huosa)){
                countsql += " and class_huosa ="+class_huosa;
                sql      += " and class_huosa ="+class_huosa;;
              }
            }
            
			// 查询条件,根据年代查询
			String year1 = data.getStrValue("year");
			if(StringUtils.isNoEmpty(year1)){
				countsql += " and year like '%"+year1+"%' ";
				sql      += " and year like '%"+year1+"%' ";
			}
			
			// 查询条件,根据出土地点查询
			String unearthedplace = data.getStrValue("unearthedplace");
			if(StringUtils.isNoEmpty(unearthedplace)){
				countsql += " and unearthedplace like '%"+unearthedplace+"%' ";
				sql      += " and unearthedplace like '%"+unearthedplace+"%' ";
			}
			
			// 查询条件,根据采集地点查询
			String collectionPlace = data.getStrValue("collectionPlace");
			if(StringUtils.isNoEmpty(collectionPlace)){
				countsql += " and collectionPlace like '%"+collectionPlace+"%' ";
				sql      += " and collectionPlace like '%"+collectionPlace+"%' ";
			}
			
			MbMusicGcxxDao gcxxdao = new MbMusicGcxxDao();
			List<Record> countlist = gcxxdao.getBySql(countsql);
			int total = countlist.get(0).getIntValue("count");//获得总记录数
			PageUtil page = new PageUtil(pagenumber, pagesize, total);
			limitsql += page.getStart()+","+pagesize;
			List<Record> list = gcxxdao.getBySql(sql+ordersql+limitsql);
			// 组装数据
			// 获取上一步骤 preflowstep
			if(list!=null&&list.size()>0){
				for(Record r:list){
					String nowflowid = r.getStrValue(MbMusicGcxx.FLOWID);
					String flowss[] = nowflowid.split("_");
					String flowmainid = flowss[1];
					String laststep = gcxxdao.getLastFlowstep(flowmainid);
					r.add("preflowstep", laststep);
				}
			}
			record.add(Status.ROWS, list);
			record.add(Status.TOTAL, total);
			record.add(Status.PAGENUMBER, pagenumber);
			record.add(Status.PAGESIZE, pagesize);
			record.add(Status.PAGETOTAL, page.getPagetotal());
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}
	
	
	/**      
	 * getBjShData 编辑流程-审核步骤-，查询待办
	 * @author wangli
	 * @param request
	 * @param response
	 * @param data
	 * @return          
	*/
	@rquestMethod(MethodNote = ReqMode.All)
	public Record getBjShData(HttpServletRequest request, HttpServletResponse response, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			int pagenumber = data.getIntValue(Status.PAGENUMBER);// 获取当前页
			int pagesize = data.getIntValue(Status.PAGESIZE);// 获取每页多少条数据
			HttpSession session = request.getSession(false);
			String userid = (String) session.getAttribute(Status.SESSION_USERID);
			// 编辑流程数据   不是最新数据，流程有效
//			String countsql = "select count(*) as count from mb_music_gcxx where isnew=0 and isrunning=1 ";
//			String sql      = "select * from mb_music_gcxx where isnew=0 and isrunning=1 ";
          String countsql = "select count(*) as count from mb_music_sjjs_lc where 1=1 ";
          String sql      = "select * from mb_music_sjjs_lc where 1=1 ";
			String ordersql = " order by id desc ";
			String limitsql = " limit ";
			// 审核人查询的流程步骤为编辑审核步骤 bj_sh
			countsql += " and flowid like '%bjsh' ";
			sql      += " and flowid like '%bjsh' ";
			
			
			MbXtglRyjsfpDao ryjsfpdao = new MbXtglRyjsfpDao();
			MbXtglJsglDao jsgldao = new MbXtglJsglDao();
			int id = Integer.parseInt(userid);
			List<Record> jslist = ryjsfpdao.getByRybm(id);
			String rolesstr = " and ( ";
			if(jslist!=null){
				for(int i=0;i<jslist.size();i++){
					Record jsobj = jslist.get(i);
					String jsbm = jsobj.getStrValue(MbXtglRyjsfp.JSBM);
					if(i>0){
						rolesstr += " or ";
					}
//					String jszdbh = jsgldao.getJsZdbh(jsbm);
					if(StringUtils.isNoEmpty(jsbm)){
						rolesstr += " assigneeroles like '%,"+jsbm+",%' ";
					}
				}
			}else{
				
			}
			rolesstr += " ) ";
//			 多选分配角色 字段包含当前人角色
			countsql += rolesstr;
			sql += rolesstr;
			
			
			// 分配人为当前人 或者 分配人为空
			countsql += " and (assigneeuser = '"+userid+"' or assigneeuser ='') ";
			sql      += " and (assigneeuser = '"+userid+"' or assigneeuser ='') ";
			
			// 查询条件,藏品号
			String collection_code = data.getStrValue("collection_code");
			if(StringUtils.isNoEmpty(collection_code)){
				countsql += " and collection_code like '%"+collection_code+"%' ";
				sql      += " and collection_code like '%"+collection_code+"%' ";
			}
			
			// 查询条件,根据名称模糊查询
			String title = data.getStrValue("yqmc");
			if(StringUtils.isNoEmpty(title)){
				countsql += " and title like '%"+title+"%' ";
				sql      += " and title like '%"+title+"%' ";
			}
			
			// 查询条件,根据八音分类查询
			String class_bayin = data.getStrValue("class_bayin");
			if(StringUtils.isNoEmpty(class_bayin)){
				countsql += " and class_bayin ="+class_bayin;
				sql      += " and class_bayin ="+class_bayin;;
			}
			
			// 查询条件,根据民间分类查询
//			String class_minjian = data.getStrValue("class_minjian");
//			if(StringUtils.isNoEmpty(class_minjian)){
//				countsql += " and class_minjian ="+class_minjian;
//				sql      += " and class_minjian ="+class_minjian;;
//			}
//			
//			// 查询条件,根据霍萨分类查询
//			String class_huosa = data.getStrValue("class_huosa");
//			if(StringUtils.isNoEmpty(class_huosa)){
//				countsql += " and class_huosa ="+class_huosa;
//				sql      += " and class_huosa ="+class_huosa;;
//			}
			// 查询条件,根据民间分类
            String class_minjian = data.getStrValue("class_minjian");
            String class_minjian_showchild = data.getStrValue("class_minjian_showchild");
            if(StringUtils.isNoEmpty(class_minjian_showchild)){
              MbXtglBaseTableServlet servlet = new MbXtglBaseTableServlet();
              if(StringUtils.isNoEmpty(class_minjian)){
                class_minjian = servlet.getAllChildrenId4Select(Integer.valueOf(class_minjian), "mb_gy_mjfl");
                countsql += " and class_minjian in ("+class_minjian+")";
                sql      += " and class_minjian in ("+class_minjian+")";
              }
            }else{
              if(StringUtils.isNoEmpty(class_minjian)){
                countsql += " and class_minjian ="+class_minjian;
                sql      += " and class_minjian ="+class_minjian;;
              }
            }
            
            // 查询条件,根据霍萨分类
//          String class_huosa = data.getStrValue("class_huosa");
//          if(StringUtils.isNoEmpty(class_huosa)){
//              countsql += " and class_huosa ="+class_huosa;
//              sql      += " and class_huosa ="+class_huosa;;
//          }
            

            String class_huosa = data.getStrValue("class_huosa");
            String class_huosa_showchild = data.getStrValue("class_huosa_showchild");
            if(StringUtils.isNoEmpty(class_huosa_showchild)){
              MbXtglBaseTableServlet servlet = new MbXtglBaseTableServlet();
              if(StringUtils.isNoEmpty(class_huosa)){
                class_huosa = servlet.getAllChildrenId4Select(Integer.valueOf(class_huosa), "mb_gy_hsfl");
                countsql += " and class_huosa in ("+class_huosa+")";
                sql      += " and class_huosa in ("+class_huosa+")";
              }
            }else{
              if(StringUtils.isNoEmpty(class_huosa)){
                countsql += " and class_huosa ="+class_huosa;
                sql      += " and class_huosa ="+class_huosa;;
              }
            }
			// 查询条件,根据年代查询
			String year = data.getStrValue("year");
			if(StringUtils.isNoEmpty(year)){
				countsql += " and year like '%"+year+"%' ";
				sql      += " and year like '%"+year+"%' ";
			}
			
			// 查询条件,根据出土地点查询
			String unearthedplace = data.getStrValue("unearthedplace");
			if(StringUtils.isNoEmpty(unearthedplace)){
				countsql += " and unearthedplace like '%"+unearthedplace+"%' ";
				sql      += " and unearthedplace like '%"+unearthedplace+"%' ";
			}
			
			// 查询条件,根据采集地点查询
			String collectionPlace = data.getStrValue("collectionPlace");
			if(StringUtils.isNoEmpty(collectionPlace)){
				countsql += " and collectionPlace like '%"+collectionPlace+"%' ";
				sql      += " and collectionPlace like '%"+collectionPlace+"%' ";
			}
			
			MbMusicGcxxDao gcxxdao = new MbMusicGcxxDao();
			List<Record> countlist = gcxxdao.getBySql(countsql);
			int total = countlist.get(0).getIntValue("count");//获得总记录数
			PageUtil page = new PageUtil(pagenumber, pagesize, total);
			limitsql += page.getStart()+","+pagesize;
			List<Record> list = gcxxdao.getBySql(sql+ordersql+limitsql);
			// 组装数据
			// 获取上一步骤 preflowstep
			if(list!=null&&list.size()>0){
				for(Record r:list){
					String nowflowid = r.getStrValue(MbMusicGcxx.FLOWID);
					String flowss[] = nowflowid.split("_");
					String flowmainid = flowss[1];
					String laststep = gcxxdao.getLastFlowstep(flowmainid);
					r.add("preflowstep", laststep);
				}
			}
			record.add(Status.ROWS, list);
			record.add(Status.TOTAL, total);
			record.add(Status.PAGENUMBER, pagenumber);
			record.add(Status.PAGESIZE, pagesize);
			record.add(Status.PAGETOTAL, page.getPagetotal());
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}
	
	@rquestMethod(MethodNote = ReqMode.All)
	@TransAnnotation(isTrans=true)
	public Record savedata(HttpServletRequest request, HttpServletResponse response, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			// 获取zdbh, 大于0为更新，等于0为插入
			int zdbh = data.getIntValue(MbMusicGcxx.ZDBH);
			String nextflow = data.getStrValue("nextflow");
			String nextdesc = data.getStrValue("nextdesc");
			String assigneeview = data.getStrValue("assigneeview");
			// 保存数据到信息表 start
			MusicSaveOrUpdateUtil gcxxutil = new MusicSaveOrUpdateUtil();
			if(zdbh>0){
				// 保存数据
				zdbh = gcxxutil.addOrMod(data);
				//保存流程数据 nextflow nextdesc
				MbMusicGcxxDao dao = new MbMusicGcxxDao();
				Record gcxxobj = dao.getById(zdbh);
				if(StringUtils.isNoEmpty(nextflow)){
					gcxxobj.add(MbMusicGcxx.NEXTFLOW, nextflow);
				}
				if(StringUtils.isNoEmpty(nextdesc)){
					gcxxobj.add(MbMusicGcxx.NEXTDESC, nextdesc);
				}
				gcxxobj.add(MbMusicGcxx.ASSIGNEEVIEW, assigneeview);
				dao.update(gcxxobj);
			}else{
				// 插入数据
				zdbh = gcxxutil.addOrMod(data);
				//生成当前成流程数据，并更新流程数据
				HttpSession session = request.getSession(false);
				String userid = (String) session.getAttribute(Status.SESSION_USERID);
				int newflowid = new flownumDao().getNewflowid();
				String flowid = "1_"+newflowid + "_bj";
				String flowstep = "数据编辑";
				int lockstatus = 1;
				int isrunning = 1;
				String assigneeusers = "," + userid+",";
				String assigneeuser = userid;
				String assigneerole = "";
				String assigneeroles = "";
				int isnew = 0 ;
				// flowid flowstep nextflow nextdesc isrunning assigneeuser lockstatus assigneeusers
				//保存流程数据
				MbMusicGcxxDao dao = new MbMusicGcxxDao();
				Record gcxxobj = dao.getById(zdbh);
				gcxxobj.add(MbMusicGcxx.NEXTFLOW, nextflow);
				gcxxobj.add(MbMusicGcxx.NEXTDESC, nextdesc);
				gcxxobj.add(MbMusicGcxx.FLOWID, flowid);
				gcxxobj.add(MbMusicGcxx.FLOWSTEP, flowstep);
				gcxxobj.add(MbMusicGcxx.ISRUNNING, isrunning);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEROLE, assigneerole);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEUSER, assigneeuser);
				gcxxobj.add(MbMusicGcxx.LOCKSTATUS, lockstatus);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEROLES, assigneeroles);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEUSERS, assigneeusers);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEVIEW, assigneeview);
				gcxxobj.add(MbMusicGcxx.ISNEW, isnew);
				dao.update(gcxxobj);
			}
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}
	
	
	/**      
	 * submitdata 
	 *   流程定义 
	 * 		编辑（1_1_bj） 单次输入
	 *      专家录入(2_1_bjlr,3_1_bjlr) 两个专家录入
	 *      编辑（4_1_bj） 专家返回编辑
	 *      编辑审核（5_1_bjsh,6_1_bjsh） 两个审核人
	 *   流程走向控制   
	 *      编辑->编辑                 nextflow=bj nextdesc=userid
	 *      编辑->专家录入         nextflow=lr nextdesc=roleid,roleid,...
	 *      专家录入->专家录入  nextflow=null nextdesc=null
	 *      专家录入->编辑         nextflow=null nextdesc=null
	 *      编辑->编辑审核       nextflow=sh nextdesc=null(不需要传，直接从后端赋值，数据审核角色和资源审核角色）
	 *      编辑->编辑审核       nextflow=sh nextdesc=null(不需要传，直接从后端赋值，数据审核角色和资源审核角色）
	 *      
	 * @author wangli
	 * @param request
	 * @param response
	 * @param data
	 * @return          
	*/
	@rquestMethod(MethodNote = ReqMode.All)
	@TransAnnotation(isTrans=true)
	public Record submitdata(HttpServletRequest request, HttpServletResponse response, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			AcquisitionUtils acutil = new AcquisitionUtils();
			HttpSession session = request.getSession(false);
			String userid = (String) session.getAttribute(Status.SESSION_USERID);
			// 获取zdbh, 大于0为更新，等于0为插入
			int zdbh = data.getIntValue(MbMusicGcxx.ZDBH);
			String nextflow = data.getStrValue("nextflow");
			String nextdesc = data.getStrValue("nextdesc");
			String flowid = "";
			// 保存数据到信息表 start
			MusicSaveOrUpdateUtil gcxxutil = new MusicSaveOrUpdateUtil();
			if(zdbh>0){
				// 保存数据
				zdbh = gcxxutil.addOrMod(data);
				//更新流程数据 nextflow nextdesc
				MbMusicGcxxDao dao = new MbMusicGcxxDao();
				Record gcxxobj = dao.getById(zdbh);
				if(StringUtils.isNoEmpty(nextflow)){
					gcxxobj.add(MbMusicGcxx.NEXTFLOW, nextflow);
				}
				if(StringUtils.isNoEmpty(nextdesc)){
					gcxxobj.add(MbMusicGcxx.NEXTDESC, nextdesc);
				}
                gcxxobj.add(MbMusicGcxx.ASSIGNEEUSER, userid);
				dao.update(gcxxobj);
			}else{
				// 插入数据
				zdbh = gcxxutil.addOrMod(data);
				//生成当前成流程数据，并更新流程数据
				int newflowid = new flownumDao().getNewflowid();
				flowid = "1_"+newflowid + "_bj";
				String flowstep = "数据编辑";
				int lockstatus = 1;
				int isrunning = 1;
				String assigneeusers = "," + userid+",";
				String assigneeuser = userid;
				String assigneerole = "";
				String assigneeroles = "";
				int isnew = 0;
				// flowid flowstep nextflow nextdesc isrunning assigneeuser lockstatus assigneeusers
				// 更新流程数据
				MbMusicGcxxDao dao = new MbMusicGcxxDao();
				Record gcxxobj = dao.getById(zdbh);
				gcxxobj.add(MbMusicGcxx.NEXTFLOW, nextflow);
				gcxxobj.add(MbMusicGcxx.NEXTDESC, nextdesc);
				gcxxobj.add(MbMusicGcxx.FLOWID, flowid);
				gcxxobj.add(MbMusicGcxx.FLOWSTEP, flowstep);
				gcxxobj.add(MbMusicGcxx.ISRUNNING, isrunning);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEROLE, assigneerole);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEUSER, assigneeuser);
				gcxxobj.add(MbMusicGcxx.LOCKSTATUS, lockstatus);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEROLES, assigneeroles);
				gcxxobj.add(MbMusicGcxx.ASSIGNEEUSERS, assigneeusers);
				gcxxobj.add(MbMusicGcxx.ISNEW, isnew);
				dao.update(gcxxobj);
			}
			MbMusicGcxxDao dao = new MbMusicGcxxDao();
			Record gcxxobj = dao.getById(zdbh);
			flowid = gcxxobj.getStrValue(MbMusicGcxx.FLOWID);
			// 先生成下一步流程数据
			// nextflow nextdesc
			if("bj".equals(nextflow)){
				// 继续编辑
				//flowid flowstep nextflow nextdesc isrunning assigneeuser lockstatus assigneeusers
				//String useridss[] = nextdesc.split(",");
				String assigneeusers = ","+nextdesc+",";
//				for(String id : useridss){
//					if(StringUtils.isNoEmpty(id)){
//						assigneeusers += id + ",";
//					}
//				}
				String flownum = flowid.split("_")[0];
				int flownumint = Integer.parseInt(flownum) + 1;
				String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_"+flowid.split("_")[2];
				String flowstep = "数据编辑";
				String assigneeuser = nextdesc;
				String  lockstatus = "1";
				String  isrunning = "1";
				String assigneerole = "";
				String assigneeroles = "";
				// 调用流程工具类
				int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
						isrunning, assigneerole, assigneeuser, 
						lockstatus, assigneeroles, assigneeusers);
				if(i==0){
					throw new Exception("流程更新失败！");
				}
			}else if("lr".equals(nextflow)){
				// 提交录入
				//flowid flowstep nextflow nextdesc isrunning assigneeuser lockstatus assigneeusers
				//String idss[] = nextdesc.split(",");
				String assigneeroles = ",";
//				for(String id : idss){
//					if(StringUtils.isNoEmpty(id)){
//						assigneeroles += id + ",";
//					}
//				}
				String flownum = flowid.split("_")[0];
				int flownumint = Integer.parseInt(flownum) + 1;
				String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_bjlr";
				String flowstep = "专家录入";
				String assigneerole = "";
				String  lockstatus = "0";
				String  isrunning = "1";
				String assigneeusers = ","+data.getStrValue("assigneeuser")+",";
				String assigneeuser = "";
//				String assigneeusers = "";
				// 调用流程工具类
				int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
						isrunning, assigneerole, assigneeuser, 
						lockstatus, assigneeroles, assigneeusers);
				if(i==0){
					throw new Exception("流程更新失败！");
				}
			}else if("sh".equals(nextflow)){
				// 提交审核
				//flowid flowstep nextflow nextdesc isrunning assigneeuser lockstatus assigneeusers
				String assigneeroles = ",5,8,";
				String flownum = flowid.split("_")[0];
				int flownumint = Integer.parseInt(flownum) + 1;
				String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_bjsh";
				String flowstep = "编辑审核";
				String assigneerole = "";
				String  lockstatus = "0";
				String  isrunning = "1";
				String assigneeuser = "";
				String assigneeusers = "";
				// 调用流程工具类
				int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
						isrunning, assigneerole, assigneeuser, 
						lockstatus, assigneeroles, assigneeusers);
				if(i==0){
					throw new Exception("流程更新失败！");
				}
			}else if("fhbj".equals(nextflow)){
				// 返回编辑

              String lastassigneeusers = gcxxobj.getStrValue(MbMusicGcxx.ASSIGNEEUSERS);
              String newassigneeusers = "";
              if(lastassigneeusers.indexOf(","+userid+",")>-1){
                String[] a_ = lastassigneeusers.split(",");
                for(String a:a_){
                  if(!a.equals(userid)&&StringUtils.isNoEmpty(a))
                    newassigneeusers += a+",";
                }
              }
              if(StringUtils.isNoEmpty(newassigneeusers)){
                gcxxobj.add(MbMusicGcxx.ASSIGNEEUSERS, ","+newassigneeusers);
                dao.update(gcxxobj);
              }else{                
                //flowid flowstep nextflow nextdesc isrunning assigneeuser lockstatus assigneeusers
                String flownum = flowid.split("_")[0];
                String mainflowid = "_"+flowid.split("_")[1]+"_bj";
                String lastbjr = dao.getLastCjr(mainflowid);
                String assigneeusers = "";//"," + lastbjr + ",";
                int flownumint = Integer.parseInt(flownum) + 1;
                String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_bj";
                String flowstep = "数据编辑";
                String assigneeuser = lastbjr;
                String  lockstatus = "1";
                String  isrunning = "1";
                String assigneerole = "";
                String assigneeroles = "";
                // 调用流程工具类
                int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
                    isrunning, assigneerole, assigneeuser, 
                    lockstatus, assigneeroles, assigneeusers);
                if(i==0){
                  throw new Exception("流程更新失败！");
                }
              }
			}else if("wc".equals(nextflow)){
				// 完成 当前审核人审核结束，提交给下一个审核人审核，没有下一个审核人则直接完成
				String shrs = gcxxobj.getStrValue(MbMusicGcxx.ASSIGNEEROLES);
				MbXtglRyjsfpDao ryjsfpdao = new MbXtglRyjsfpDao();
				MbXtglJsglDao jsgldao = new MbXtglJsglDao();
				int id = Integer.parseInt(userid);
				List<Record> jslist = ryjsfpdao.getByRybm(id);
				if(jslist!=null){
					for(Record js : jslist){
						//String jszdbh = jsgldao.getJsZdbh(js.getStrValue(MbXtglRyjsfp.JSBM)) + ",";
                        String jszdbh = js.getStrValue(MbXtglRyjsfp.JSBM) + ",";
						if(shrs.indexOf(jszdbh)>-1){
							shrs = shrs.replaceAll(jszdbh, "");
						}
					}
				}
				// 取出当前审核人角色后，还有未录入的审核人角色，则继续审核人步骤，否则完成流程
				String shrsbz = shrs.replaceAll(",", "");
				if(StringUtils.isNoEmpty(shrsbz)){
					// 继续审核人审核
					String assigneeroles = shrs;
					String flownum = flowid.split("_")[0];
					int flownumint = Integer.parseInt(flownum) + 1;
					String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_bjsh";
					String flowstep = "编辑审核";
					String assigneerole = "";
					String  lockstatus = "0";
					String  isrunning = "1";
					String assigneeuser = "";
					String assigneeusers = "";
					// 调用流程工具类
					int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
							isrunning, assigneerole, assigneeuser, 
							lockstatus, assigneeroles, assigneeusers);
					if(i==0){
						throw new Exception("流程更新失败！");
					}
				}else{
					// 完成流程
					String collection_code = gcxxobj.getStrValue(MbMusicGcxx.COLLECTIONCODE);
					try {
						Record oldgcxx = dao.getIsNewData(collection_code);
						// 设置旧数据为历史数据
						if(oldgcxx!=null){
							oldgcxx.add(MbMusicGcxx.ISNEW, 0);
							dao.update(oldgcxx);
						}
					} catch (Exception e) {
					}
					// 设置当前数据为最新数据
					gcxxobj.add(MbMusicGcxx.ISNEW, 1);
					gcxxobj.add(MbMusicGcxx.ISRUNNING, 0);
					dao.update(gcxxobj);
				}
			}else{
				// 专家录入完成，继续下一个专家录入或者返回给最后编辑人
				String zjrs = gcxxobj.getStrValue(MbMusicGcxx.ASSIGNEEROLES);
				MbXtglRyjsfpDao ryjsfpdao = new MbXtglRyjsfpDao();
				MbXtglJsglDao jsgldao = new MbXtglJsglDao();
				int id = Integer.parseInt(userid);
				List<Record> jslist = ryjsfpdao.getByRybm(id);
				if(jslist!=null){
					for(Record js : jslist){
//						String jszdbh = jsgldao.getJsZdbh(js.getStrValue(MbXtglRyjsfp.JSBM)) + ",";
                        String jszdbh = js.getStrValue(MbXtglRyjsfp.JSBM) + ",";
						if(zjrs.indexOf(jszdbh)>-1){
							zjrs = zjrs.replaceAll(jszdbh, "");
						}
					}
				}
				// 取出当前专家角色后，还有未录入的专家角色，则继续专家录入步骤，否则返回给最后编辑人
				String zjrsbz = zjrs.replaceAll(",", "");
				if(StringUtils.isNoEmpty(zjrsbz)){
					// 继续专家录入
					String assigneeroles = zjrs;
					String flownum = flowid.split("_")[0];
					int flownumint = Integer.parseInt(flownum) + 1;
					String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_bjlr";
					String flowstep = "专家录入";
					String assigneerole = "";
					String  lockstatus = "0";
					String  isrunning = "1";
					String assigneeuser = "";
					String assigneeusers = "";
					// 调用流程工具类
					int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
							isrunning, assigneerole, assigneeuser, 
							lockstatus, assigneeroles, assigneeusers);
					if(i==0){
						throw new Exception("流程更新失败！");
					}
				}else{
					// 返回给最后编辑人
					String flownum = flowid.split("_")[0];
					String mainflowid = "_"+flowid.split("_")[1]+"_bj";
					String lastbjr = dao.getLastCjr(mainflowid);
					String assigneeusers = ","+lastbjr + ",";
					int flownumint = Integer.parseInt(flownum) + 1;
					String newflowid = flownumint +"_"+ flowid.split("_")[1]+"_bj";
					String flowstep = "数据编辑";
					String assigneeuser = lastbjr;
					String  lockstatus = "1";
					String  isrunning = "1";
					String assigneerole = "";
					String assigneeroles = "";
					// 调用流程工具类
					int i = acutil.getMusicGcxxID(zdbh, newflowid, flowstep, nextflow, nextdesc, 
							isrunning, assigneerole, assigneeuser, 
							lockstatus, assigneeroles, assigneeusers);
					if(i==0){
						throw new Exception("流程更新失败！");
					}
				}
			}
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}
	
	@rquestMethod(MethodNote = ReqMode.All)
	@TransAnnotation(isTrans=true)
	public Record lockunlock(HttpServletRequest request, HttpServletResponse response, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			HttpSession session = request.getSession(false);
			String userid = (String) session.getAttribute(Status.SESSION_USERID);
			String flowid = data.getStrValue(MbMusicGcxx.FLOWID);
			MbMusicGcxxDao dao = new MbMusicGcxxDao();
			Record gcxx = dao.getByFlowid(flowid);
			int lockstatus = gcxx.getIntValue(MbMusicGcxx.LOCKSTATUS);
			if(lockstatus==0){
				// 未锁定 现进行锁定操作
				String folwidss[] = flowid.split("_");
				if("bj".equals(folwidss[2])){
					// 编辑步骤 - 更新锁定人和状态，统一赋值
				}else if("bjlr".equals(folwidss[2])){
					// 专家录入 - 更新锁定人和状态，统一赋值,锁定角色
					String zjrs = gcxx.getStrValue(MbMusicGcxx.ASSIGNEEROLES);
					MbXtglRyjsfpDao ryjsfpdao = new MbXtglRyjsfpDao();
					int id = Integer.parseInt(userid);
					List<Record> jslist = ryjsfpdao.getByRybm(id);
					String assigneerole = "";
					if(jslist!=null){
						for(Record js : jslist){
							String jsbm = js.getStrValue(MbXtglRyjsfp.JSBM) + ",";
							if(zjrs.indexOf(jsbm)>-1){
								assigneerole = jsbm;
							}
						}
					}
					gcxx.add(MbMusicGcxx.ASSIGNEEROLE, assigneerole);
				}else{
					// 审核 - 更新锁定人和状态，统一赋值,锁定角色
					String zjrs = gcxx.getStrValue(MbMusicGcxx.ASSIGNEEROLES);
					MbXtglRyjsfpDao ryjsfpdao = new MbXtglRyjsfpDao();
					int id = Integer.parseInt(userid);
					List<Record> jslist = ryjsfpdao.getByRybm(id);
					String assigneerole = "";
					if(jslist!=null){
						for(Record js : jslist){
							String jsbm = js.getStrValue(MbXtglRyjsfp.JSBM) + ",";
							if(zjrs.indexOf(jsbm)>-1){
								assigneerole = jsbm;
							}
						}
					}
					gcxx.add(MbMusicGcxx.ASSIGNEEROLE, assigneerole);
				}
				gcxx.add(MbMusicGcxx.ASSIGNEEUSER, userid);
				gcxx.add(MbMusicGcxx.LOCKSTATUS, 1);
			}else{
				// 已锁定 现进行解锁操作
				String folwidss[] = flowid.split("_");
				if("bj".equals(folwidss[2])){
					// 编辑步骤 - 更新锁定人和状态，统一赋值
				}else if("bjlr".equals(folwidss[2])){
					// 专家录入 - 更新锁定人和状态，统一赋值,锁定角色
					gcxx.add(MbMusicGcxx.ASSIGNEEROLE, "");
				}else{
					// 审核 - 更新锁定人和状态，统一赋值,锁定角色
					gcxx.add(MbMusicGcxx.ASSIGNEEROLE, "");
				}
				gcxx.add(MbMusicGcxx.ASSIGNEEUSER, "");
				gcxx.add(MbMusicGcxx.LOCKSTATUS, 0);
			}
			dao.update(gcxx);
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}

	@rquestMethod(MethodNote = ReqMode.Get)
	public Record getdata(HttpServletRequest request, HttpServletResponse response, Record data){
	    String[] tables = {MbMusicXzxx.MB_MUSIC_XZXX_TABLE_NAME,
	        MbMusicWhrlxxx.MB_MUSIC_WHRLXXX_TABLE_NAME,
	        MbMusicYxxx.MB_MUSIC_YXXX_TABLE_NAME};
	    Record record = new Record();
	    try {
	      int gcxxid = data.getIntValue("gcxxid");
	      MbMusicGcxxDao dao = new MbMusicGcxxDao();
	      Record gcxx = dao.getById(gcxxid);
	      if (gcxx == null) throw new Exception("查询不到馆藏信息！");
	      for (String table : tables) {
	        String sql = "select * from " + table + " where gcxxid=" + gcxxid;
	        List<Record> list = dao.getBySql(sql);
	        if (!list.isEmpty()) {
	          Record r = list.get(0);
	          for (String fld : r.getAllFlds()) {
	            gcxx.add(fld, r.getValue(fld));
	          }
	        }
	      }      


          String[] imagesByZdbh = new String[]{"formDrawing", "improveStateImage","mediatorMaterialImage"
              ,"vibrationTransferMaterialImage", "vibrationTransferStructImage","spectrumAnalysisImage",
              "resonatorMaterialImage","resonatorStrutImage","spectrumImage","spectrumAnalysisImage",
              "mediatorStructImage","vibrationTransferStructImage","structImage",
              "resonatorMaterialImage","resonatorStrutImage","spectrumImage","spectrumAnalysisImage"
              ,"mediatorStructImage","originImage","musicScoreImage","historyImage","folkloreImage","faithImage"};
          String[] audioByZdbh = new String[]{"pitchAudio", "toneAudio", "temperamentAudio", 
              "bestRegisterAudio", "toneMethodAudio", "mainPartSoundAudio","rangeAudio","mediatorShapeAudio",
              "mainPartSoundAudio","faithAudio","historyAudio","originAudio","folkloreAudio"};
          String[] videoByZdbh = new String[]{"voiceMechanismVideo", "provokeVideo","structVideo",
              "techniquesVideo","inheritTeachVideo","techniquesVideo","inheritTeachVideo","faithVideo",
              "originVideo","folkloreVideo","historyVideo"};
          String[] ThreedimensionalmodelByZdbh = new String[]{};
          String[] LiteratureByZdbh = new String[]{};
          
          MbManageImageDao imagedao = new MbManageImageDao();
          for (String resource : imagesByZdbh) {
            List<Record> ls = imagedao.getBySql("select * from "+MbManageImage.MB_MANAGE_IMAGE_TABLE_NAME
                +" where zdbh='" + gcxx.getStrValue(resource) + "'");
            if (!ls.isEmpty()) {
              gcxx.add(resource + "1", ls.get(0).getStrValue("title"));
            }
          }
          MbManageAudiofrequencyDao audiodao = new MbManageAudiofrequencyDao();
          for (String resource : audioByZdbh) {
            List<Record> ls = audiodao.getBySql("select * from "
                                                +MbManageAudiofrequency.MB_MANAGE_AUDIOFREQUENCY_TABLE_NAME
                +" where zdbh='" + gcxx.getStrValue(resource) + "'");
            if (!ls.isEmpty()) {
              gcxx.add(resource + "1", ls.get(0).getStrValue("title"));
            }
          }
          MbManageVideoDao videodao = new MbManageVideoDao();
          for (String resource : videoByZdbh) {
            List<Record> ls = videodao.getBySql("select * from "+MbManageVideo.MB_MANAGE_VIDEO_TABLE_NAME
                +" where zdbh='" 
          + gcxx.getStrValue(resource) + "'");
            if (!ls.isEmpty()) {
              gcxx.add(resource + "1", ls.get(0).getStrValue("title"));
            }
          }
          MbManageThreedimensionalmodelDao tdmdao = new MbManageThreedimensionalmodelDao();
          for (String resource : ThreedimensionalmodelByZdbh) {
            List<Record> ls = tdmdao.getBySql("select * from "
          +MbManageThreedimensionalmodel.MB_MANAGE_THREEDIMENSIONALMODEL_TABLE_NAME
          +" where zdbh='" + gcxx.getStrValue(resource) + "'");
            if (!ls.isEmpty()) {
              gcxx.add(resource + "1", ls.get(0).getStrValue("title"));
            }
          }
          MbManageLiteratureDao literaturedao = new MbManageLiteratureDao();
          for (String resource : LiteratureByZdbh) {
            List<Record> ls = literaturedao.getBySql("select * from "
                +MbManageLiterature.MB_MANAGE_LITERATURE_TABLE_NAME
                +" where zdbh='" + gcxx.getStrValue(resource) + "'");
            if (!ls.isEmpty()) {
              gcxx.add(resource + "1", ls.get(0).getStrValue("title"));
            }
          }
          
          
          
//	      String[] images = new String[]{"mediatorMaterialImage", "spectrumAnalysisImage"};
//	      MbManageImageDao idao = new MbManageImageDao();
//	      for (String image : images) {
//	        List<Record> ls = idao.getBySql("select * from mb_manage_image where fileid='" + gcxx.getStrValue(image) + "'");
//	        if (!ls.isEmpty()) {
//              gcxx.add(image + "1", ls.get(0).getStrValue("title"));
//            }
//	      }
          

          String[] baseTables = {MbGyHsfl.MB_GY_HSFL_TABLE_NAME,MbGyMjfl.MB_GY_MJFL_TABLE_NAME};
          String[] fields = {"class_huosa","class_minjian"};
          MbXtglBaseTableServlet baseTableServlet = new MbXtglBaseTableServlet();
          for(int i=0;i<fields.length;i++){
            String f=fields[i];
            String value = gcxx.getStrValue(f);
            String text = "";
            if(StringUtils.isNoEmpty(value)){
              text = baseTableServlet.getNameById(baseTables[i],Integer.valueOf(value));
            }
            gcxx.add(f+"_text", text);
          }
	      record.add(Status.SATUS, Status.OK);
	      record.add(Status.ROWS, gcxx);
	    } catch (Exception e) {
	      record.add(Status.SATUS, Status.FAILED);
	      record.add(Status.MSG, "数据异常！");
	    }
	    return record;
	  }

	@rquestMethod(MethodNote = ReqMode.All)
	@TransAnnotation(isTrans=true)
	public Record deletedata(HttpServletRequest request, HttpServletResponse response, Record data){
		Record record = new Record();
		record.add(Status.SATUS, Status.OK);
		try {
			// 获取zdbh, 大于0为更新，等于0为插入
			int zdbh = data.getIntValue(MbMusicGcxx.ZDBH);
			MbMusicGcxxDao dao = new MbMusicGcxxDao();
			Record obj = dao.getById(zdbh);
			// 流程失效，相当于删除，历史数据
			obj.add(MbMusicGcxx.ISRUNNING, 0);
			if(!dao.update(obj)){
				record.add(Status.SATUS, Status.FAILED);
				record.add(Status.MSG, "删除失败！");
			}
		} catch (Exception e) {
			record.add(Status.SATUS, Status.FAILED);
			record.add(Status.MSG, "数据异常！");
		}
		return record;
	}

}
